<?php
/**
 * @package    com.promobico.mcm
 * @subpackage mvm
 * @link promobico.com
 * @license  All rights reserved.
 */
 
// no direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view');
 
/**
 * HTML View class for the MvmView Component
 *
 * @package    mvm
 */
 
class MvmViewCategory extends JView
{
    function display($tpl = null)
    {
		$show_prices  = _SHOW_PRICES;
		if($show_prices == '1'){
			JLoader::import('helpers.calculationh', JPATH_COMPONENT);
		}
		$this->assignRef('show_prices', $show_prices);

		$document = JFactory::getDocument();

		$mainframe = JFactory::getApplication();
		$pathway = $mainframe->getPathway();

		/* Set the helper path */
		$this->addHelperPath(JPATH_COMPONENT.'helpers');

		/* Load helpers */
		//$this->loadHelper('image');

		$categoryModel = $this->getModel('category');
		$productModel = $this->getModel('product');
	    $categoryId = JRequest::getInt('category_id', 0);
	    $vendorId = 1;

	    $category = $categoryModel->getCategory($categoryId);
	    if(empty($category->vendor_id)){
	    	return;
	    }
	    

	    $this->assignRef('category', $category);


	    /* Load the products in the given category */
	    $products = $productModel->getProductsInCategory($categoryId);
	    $this->assignRef('products', $products);

	    $total = $categoryModel->countProducts($categoryId);
	    $this->assignRef('total', $total);

	    $pagination = $productModel->getPagination($categoryId);
	    $this->assignRef('pagination', $pagination);
	    $orderByList = $productModel->getOrderByList();
	    $this->assignRef('orderByList', $orderByList);
	    
	    JLoader::import('helpers.mvmuri',JPATH_COMPONENT);
	    
//	    JLoader::import('helpers.permissions', JPATH_COMPONENT);
//		$showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings
//		$this->assignRef('showBasePrice', $showBasePrice);

        parent::display($tpl);
    }
        
}